<?php
@session_start();
$PurviewLevel=2;
$CheckChannelID=0;  
$PurviewLevel_Others="tongjing_msg";

require("../../inc/common.inc.php");
require_once("../Admin_ChkPurview.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<TITLE>铭讯EOS网站后台管理</TITLE>
<Meta name="Keywords" Content="济南网站建设 济南网站制作 山东网站建设 济南铭讯软件有限公司">
<Meta name="Description" Content="济南网站制作：铭讯软件专业服务优秀企业，致力于网站建、设网站推广、网络营销一体的全访位网络服务商">
<link rel="stylesheet" href="../images/style.css" type="text/css">
</head>
<body> 
<?php
require("../mx_head.php");
?>
<div class="right">
<div class="gk">
	<div class="ti2 fl">消息统计</div>
	<ul class="fr">
		<?php
		$vpp=$db->listcount("mx_tuisong_vpp_log"," ");
		$app=$db->listcount("mx_tuisong_app_log","");
		$reply=$db->listcount("mx_tuisong_reply_log","");
		$tjzong=$vpp+$app+$reply;
		?>
		<li><span class="c1"><?php echo $vpp;?></span><span>微信</span></li>
		<li class="line"></li>
		<li><span class="c2"><?php echo $app;?></span><span>APP信息</span></li>
		<li class="line"></li>
		<li><span class="c3"><?php echo $reply;?></span><span>机器人信息</span></li>
		<li class="line"></li>
		<li><span class="c4"><?php echo $tjzong;?></span><span>总计</span></li>
	</ul>
	<div class="clear"></div>
	</div>
	<div class="clear"></div>
	<div class="height15"></div>
	<div class="clear"></div>
	<div class="xm2">
		<h1 class="fl">昨日信息统计</h1>
		<div class="clear"></div>
	</div>
	<div class="xm2_b">
				<div class="height15"></div>
				<div class="zengzhang" style="height:80px;">
				<?php $lastinfo=$db->getinfo("select * from mx_tj_msg order by tjdate desc limit 1");?>
				<table width="90%" height="80" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="22%" class="bor_r"><div class="w115"><div class="span1">微信信息</div><div class="span2"><?php echo $lastinfo["vpp"];?></div></div></td>
                    <td width="26%" class="bor_r"><div class="w115"><div class="span1">APP推送</div><div class="span2"><?php echo $lastinfo["app"];?></div></div></td>
                    <td width="26%" class="bor_r"><div class="w115"><div class="span1">机器人信息</div><div class="span2"><?php echo $lastinfo["reply"];?></div></div></td>
                    <td width="26%"><div class="w115"><div class="span1">信息总计</div><div class="span2"><?php echo $lastinfo["tjzong"];?></div></div></td>
                  </tr>
                </table>
				</div>
				<div class="height15"></div>
	</div>
	
		<div class="clear"></div>
		<div class="height15"></div>
		<div class="xm2">
			<h1 class="fl">曲线图</h1>
			<div class="clear"></div>
		</div>
		<div class="xm2_b">
		<div class="height15"></div>
		<?php
		$startdate=formatdate($startdate);
		$enddate=formatdate($enddate);
		if ($startdate=="" or $enddate==""){
			$enddate=date("Y-m-d");
			$startdate=date("Y-m-d",strtotime("$enddate - 30 day"));
		}
		?>
		    <table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">
              <tr>
                <td width="190" align="center">
<script>
	var jQuery_1 = $.noConflict(true);
    var minValidDate = 1372608000;
</script>	
<link rel="stylesheet" type="text/css" href="../js/date.css" charset="utf-8">
<script type="text/javascript" src="../js/gri.dateRange.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/gri.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/mta.js" charset="utf-8"></script>
<!--==时间范围start==-->
<form name="form1" id="form1" action="tj_msg.php" method="get">
<input type="text" name="selectdate" id="selectdate" class="input1" style="width:180px;">
<input type="hidden" name="startdate" value="<?php echo $startdate;?>">
<input type="hidden" name="enddate" value="<?php echo $enddate;?>">
<input type="hidden" name="actions" value="<?php echo $actions;?>" />
</form>
<!--==时间范围end==-->
 
<script type="text/javascript"> 
    //应用的初始化参数
    var initParams = {
	"start_date": "<?php echo $startdate;?>",
	"end_date": "<?php echo $enddate;?>",	
	"need_compare": 1,
	};
 
    jQuery_1(document).ready(function(){
 
        var dateObj = {
            inputId:'selectdate',
            target:'datePicker',
            startDate: initParams.start_date || '',
            endDate: initParams.end_date || '',
            startCompareDate: initParams.start_compare_date || '',
            endCompareDate: initParams.end_compare_date || '',
            needCompare: initParams.need_compare || '1',
            defaultText : ''|| ' 至 ',
            singleCompare : '',
            isTodayValid: 0,
            minValidDate: minValidDate
        };
 
        //MTA.Page.Condition.source = new MTA.Selector('#div_source', 'source', initParams.source, 'buildData');
 
        MTA.Report.initialize(dateObj, 'buildData');
 
        //页面tips
    });
	function selectdate_submit(){
		var selectdatestr=document.form1.selectdate.value;
		if (selectdatestr!=""){
			selectdatearr=selectdatestr.split(' 至 ');
			if (selectdatearr.length==2){
				document.form1.startdate.value=selectdatearr[0];
				document.form1.enddate.value=selectdatearr[1];
				document.form1.submit();
			}
		}
	}
</script>
				</td>
                <td>
				<div class="an<?php if (trim($actions)=="zongji"){echo "1";}else{echo "2";}?>"><a href="tj_msg.php?actions=zongji">总计</a></div>
				<div class="an<?php if (trim($actions)=="weixin"){echo "1";}else{echo "2";}?>"><a href="tj_msg.php?actions=weixin">微信信息</a></div>
				<div class="an<?php if (trim($actions)=="app"){echo "1";}else{echo "2";}?>"><a href="tj_msg.php?actions=app">APP信息</a></div>
				<div class="an<?php if (trim($actions)=="jiqiren"){echo "1";}else{echo "2";}?>"><a href="tj_msg.php?actions=jiqiren">机器人信息</a></div></td>
              </tr>
            </table>
			<div class="height15"></div>
				<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td>
<?php
$str="";
if ($startdate!=""){
	$str.=" and tjdate>='$startdate' ";
}
if ($enddate!=""){
	$str.=" and tjdate<='$enddate' ";
}
$rs=$db->excu("select * from mx_tj_msg where id>0 $str order by tjdate asc,id asc");
if ($db->num_rows($rs)>0){
	while ($rsdb=$db->fetch_array($rs)){
		$thisdate[]=$rsdb;
	}
}
?>
<script src="../js/jquery.min.js"></script>
<script src="../js/highcharts/tongji.js"></script>
<script src="../js/highcharts/highcharts.js"></script>
<script src="../js/handsontable/jquery.handsontable.full.js"></script>
<link rel="stylesheet" media="screen" href="../js/handsontable/jquery.handsontable.full.css">
<div id="data_div"></div>
<div id="charts" style="width: 99%; margin: 0; padding: 0;"></div>
<script type="text/javascript"> 
<!--
<?php
if (is_array($thisdate)){
$thisdatenum=count($thisdate);
if ($thisdatenum<10){
	$ge=1;
}
else if ($thisdatenum<=20){
	$ge=2;
}
else if ($thisdatenum<=40){
	$ge=3;
}
else if ($thisdatenum<=50){
	$ge=5;
}
else{
	$ge=10;
}
	if (trim($actions)=="weixin"){
?>
var data = [
	["", "微信信息"],
	<?php
	$i=0;
	foreach ($thisdate as $key =>$value){
		if (($i%$ge==0) or ($i%$ge!=0 and $i==$thisdatenum-1)){
			echo '["'.date("m/d",strtotime($value["tjdate"])).'",'.$value["vpp"].'],';
		}
		else{
			echo '[" ",'.$value["vpp"].'],';
		}
		$i++;
	}
	?>
];
<?php }
	elseif (trim($actions)=="app"){
?>
var data = [
	["", "APP信息"],
	<?php
	$i=0;
	foreach ($thisdate as $key =>$value){
		if (($i%$ge==0) or ($i%$ge!=0 and $i==$thisdatenum-1)){
			echo '["'.date("m/d",strtotime($value["tjdate"])).'",'.$value["app"].'],';
		}
		else{
			echo '[" ",'.$value["app"].'],';
		}
		$i++;
	}
	?>
];
<?php }
	elseif (trim($actions)=="jiqiren"){
?>
var data = [
	["", "机器人回复"],
	<?php
	$i=0;
	foreach ($thisdate as $key =>$value){
		if (($i%$ge==0) or ($i%$ge!=0 and $i==$thisdatenum-1)){
			echo '["'.date("m/d",strtotime($value["tjdate"])).'",'.$value["reply"].'],';
		}
		else{
			echo '[" ",'.$value["reply"].'],';
		}
		$i++;
	}
	?>
];
<?php }
	elseif (trim($actions)=="zongji"){
?>
var data = [
	["", "总计"],
	<?php
	$i=0;
	foreach ($thisdate as $key =>$value){
		if (($i%$ge==0) or ($i%$ge!=0 and $i==$thisdatenum-1)){
			echo '["'.date("m/d",strtotime($value["tjdate"])).'",'.$value["tjzong"].'],';
		}
		else{
			echo '[" ",'.$value["tjzong"].'],';
		}
		$i++;
	}
	?>
];
<?php }
	else{
?>
var data = [
	["", "总计", "微信信息", "APP信息", "机器人回复"],
	<?php
	$i=0;
	foreach ($thisdate as $key =>$value){
		if (($i%$ge==0) or ($i%$ge!=0 and $i==$thisdatenum-1)){
			echo '["'.date("m/d",strtotime($value["tjdate"])).'",'.$value["tjzong"].','.$value["vpp"].','.$value["app"].','.$value["reply"].'],';
		}
		else{
			echo '[" ",'.$value["tjzong"].','.$value["vpp"].','.$value["app"].','.$value["reply"].'],';
		}
		$i++;
	}
	?>
];
<?php
	}
}
?>
 

$(function(){
	$(document).ready(function() {
		var table = $('#data_div').handsontable({
			minRows: 1,
			minCols: 5,
			minSpareRows: 1,
			minSpareCols: 1,
			rowHeaders: true,
			colHeaders: true,
			data: data
		}).data('handsontable');
			var datagrid = table.getData();
			var type = "line";
			var title = "";
			var ytitle = "";
			show_chart(type, title, ytitle,datagrid);
			return false;
	});
});
 
//-->
</script>
					</td>
                  </tr>
                </table>
				<div class="height15"></div>
	  </div>
		<div class="clear"></div>
		<div class="height15"></div>
        <div class="xm2">
          <h1 class="fl">详细数据</h1>
          <div class="clear"></div>
        </div>
		<div class="xm2_b">
		  <div class="height15"></div>
	
	<script type="text/javascript" src="../js/jquery.tablesorter.js"></script>
	<script type="text/javascript" src="../js/jquery.tablesorter.pager.js"></script>
<script type="text/javascript" id="js">$(document).ready(function() {
	$("table").tablesorter();
}); </script>
          <table width="98%" border="0" align="center" cellpadding="9" cellspacing="1" bgcolor="#CCCCCC" class="table_southidc" id="table">
		  <thead>
            <tr align="center">
              <th width="16%"><span>时间</span></th>
              <th width="21%"><span>总计</span></th>
              <th width="21%"><span>微信信息</span></th>
              <th width="21%"><span>APP信息</span></th>
              <th width="21%"><span>机器人回复</span></th>
            </tr>
			</thead>
			<tbody>
			<?php
			if (is_array($thisdate)){
			foreach ($thisdate as $key =>$value){
			?>
            <tr align="center" class="list" >
              <td><?php echo $value["tjdate"];?></td>
              <td><?php echo $value["tjzong"];?></td>
              <td><?php echo $value["vpp"];?></td>
              <td><?php echo $value["app"];?></td>
              <td><?php echo $value["reply"];?></td>
            </tr>
			<?php
			}
			}
			else{
			?>
			<tr class="list"><td align="center" colspan="4">暂无信息</td></tr>
			<?php
			}
			?>
			</tbody>
          </table>
		  
		  <div class="height15"></div>
	  </div>
		<div class="clear"></div>
  </div>
	
</div>
</div>
<?php require("../mx_foot.php");?>
</body>
</html>
